package com.kaifamiao.listener;

import org.tinylog.Logger;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionListener implements HttpSessionListener {

    // 每成功创建一个HttpSession实例就调用一次该方法
    @Override
    public void sessionCreated(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        Logger.trace("已经成功创建[{}]会话对象", session.getId() );
        Logger.trace( "会话默认闲置时间 {}秒", session.getMaxInactiveInterval());
    }

    // 每成功销毁一个HttpSession实例就调用一次该方法
    @Override
    public void sessionDestroyed(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        Logger.trace("已经成功销毁[{}]会话对象", session.getId() );
    }

}
